package com.test.action;

import java.util.ArrayList;
import java.util.List;

import com.test.bean.User;
import com.test.dao.DaoTool;
import com.test.vo.PageView;

public class UtilAction {

	private String requestPage="1";
	public List dataList = new ArrayList();
	private DaoTool daoTool;
	public PageView pageView=new PageView();
	private int pageCount=10;
    
	public String exec() {
		
		System.out.println("----------------this is exec--utilAction--------------------");
		System.out.println("接受到的请求参数："+requestPage);
		buildPageView();
		return "success";
	}
	
	public void buildPageView(){
		int total=(int)daoTool.getTotalRecord(User.class);
		 int requestpageInt=Integer.parseInt(requestPage);
		 if(requestpageInt<0){
			 requestpageInt=0;
		 }if(requestpageInt>=total){
			 requestpageInt=total;
		 }
		pageView.setList(daoTool.getStartTend(requestpageInt, pageCount));
		pageView.setTotalRecord((int)daoTool.getTotalRecord(User.class));
		pageView.setCurentPage(Integer.parseInt(requestPage));
	}

	public int getPageCount() {
		return pageCount;
	}

	public void setPageCount(int pageCount) {
		this.pageCount = pageCount;
	}


	

	public DaoTool getDaoTool() {
		return daoTool;
	}

	public void setDaoTool(DaoTool daoTool) {
		this.daoTool = daoTool;
	}

	public List getDataList() {
		return dataList;
	}

	public void setDataList(List dataList) {
		this.dataList = dataList;
	}




	public PageView getPageView() {
		return pageView;
	}

	public void setPageView(PageView pageView) {
		this.pageView = pageView;
	}

	

	public String getRequestPage() {
		return requestPage;
	}

	public void setRequestPage(String requestPage) {
		this.requestPage = requestPage;
	}

	public int getStartPage() {
		
		return 	this.getPageView().getStartPage();
		
	}


}
